package dnem;

import org.junit.After;
import org.junit.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

public class buxfer {
    private WebDriver driver;

    @BeforeSuite
    public void setUp() throws InterruptedException {
        driver=new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("http://www.buxfer.com/");
        Pagelogin log = new Pagelogin(driver);
    }

    @Test
    public void testSearch() {
        Pagemenu menu = new Pagemenu(driver);
        Pageresult result = menu.navigate("tab-add_transaction");
        assertTrue(result.getFirstbred(".//div[text() = 'Add Transaction']").contains("Add Transaction"));
    }

    @Test
    public void testSearch2() {
        Pagemenu menu = new Pagemenu(driver);
        Pageresult result = menu.navigate("tab-reports");
        assertTrue(result.getFirstbred(".//div[text() = 'Reports']").contains("Reports"));
    }

    @Test
    public void testSearch3() {
        Pagemenu menu = new Pagemenu(driver);
        Pageresult result = menu.navigate("tab-budgets");
        assertTrue(result.getFirstbred(".//div[text() = 'Budgets']").contains("Budgets"));
    }

    @Test
    public void testSearch4() {
        Pagemenu menu = new Pagemenu(driver);
        Pageresult result = menu.navigate("tab-reminders");
        assertTrue(result.getFirstbred(".//div[text() = 'Reminders']").contains("Reminders"));
    }

    @Test
    public void testSearch5() {
        Pagemenu menu = new Pagemenu(driver);
        Pageresult result = menu.navigate("tab-forecast");
        assertTrue(result.getFirstbred(".//div[text() = 'Forecast']").contains("Forecast"));
    }

    @Test
    public void testSearch6() {
        Pagemenu menu = new Pagemenu(driver);
        Pageresult result = menu.navigate("tab-payments");
        assertTrue(result.getFirstbred(".//div[text() = 'Payments']").contains("Payments"));
    }

    @AfterSuite
    public void CloseDown()throws InterruptedException{
        Pagedelete log2=new Pagedelete(driver);
        driver.quit();
    }
}
